#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std; 

class Solution1{
public:
    string replaceSpace(string s) {
        int len=s.length();
        if(s.length()<=0){
            return "";
        }
        int spnum=0;
        for(int i=0;i<len;i++){
            if(s[i]==' '){
                spnum++;
            }
        }
        while(spnum--){
			s.replace(s.find(' '),1,"%20");
		}
        return s;
    }
};
class Solution {
public:
    string replaceSpace(string s) {
        int len=s.length();
        string ans,tmp="%20";
        for(int i=0;i<len;i++){
            if(s[i]==' ')
                ans+=tmp;
            else
                ans+=s[i];
        }
        return ans;
    }
};


#define TA "hello world"

int main(){
    string str=TA;
	Solution s;
	
	cout << s.replaceSpace(str)<<endl;
	/*
	string ss(TA);
	ss.replace(ss.find(' '),1,"20%");
	cout <<ss <<endl;
	*/
	
	
	return 0;
}
